<?php 
## include required files
/*******************************/
require_once '../model/config.php';
## Paginaton class
require_once ("../includes/classes/pagination_class.php");

/*******************************/
## check is another acessing this module
if($_SESSION['admin_id'] != 2) {
	## techmodi admin user
	header('location:'.SITE_URL.'/admin/home.php');	
	exit;
}

## Create Objects
/*******************************/
$configObj = new Model_Config();
/*******************************/

/*******************************/
##Fetch all config settings from database

##  --------- Pagination part first start --------------##
	if( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] != "" ) {
		$pageNum = $_GET[ 'page' ];
	} else {
		$pageNum = 1;
	} 
	$rowsPerPage = ROW_PER_PAGE;
	$pageName = "home.php?q=defaultsettings"; 
	## Count all the records
	$configArray = $configObj->getConfigSettings();
	$total_rows = count($configArray);
	$offset	= ($pageNum - 1) * $rowsPerPage;
	$smarty->assign('page', $pageNum);
##  --------- Pagination part first end --------------##


##  --------- Pagination part second start --------------##
	$newid = $pageNum * $rowsPerPage - $rowsPerPage + 1;
	$smarty->assign('newid', $newid);
	$configArray = $configObj->getConfigSettings($rowsPerPage,$offset);
	//echo "<pre>"; print_r($cmsArray);exit;
	$smarty->assign('configArray', $configArray);
	if($total_rows > ROW_PER_PAGE) {
		$pg = new pagination();					// CREATING OBJECT OF THE PAGINATION CLASS
		$pgnation = $pg->pagination_admin( $total_rows , $rowsPerPage , $pageNum , $pageName , $other_id, $class);	
		$smarty-> assign("pagination",$pgnation);
	}
##  --------- Pagination part second end --------------##	

## Assign session message to smarty variable and unset session variable
if($_SESSION['msg'] != '') {
	$smarty->assign('msg', $_SESSION['msg']);	
	unset($_SESSION['msg']);
}

## Unset all the objects created which are on this page
unset($configObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'settings/defaultsettings.tpl');
unset($smarty);
?>